<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <title>{$Think.config.website.name}</title>
    <link rel="stylesheet" href="__WECHAT__/css/weui.min.css">
    <link rel="stylesheet" href="__WECHAT__/css/weui-common.css">
</head>
<body ontouchstart>
<div class="container" id="container">
    <div class="page input js_show">
        <div class="page__hd">
            <h1 class="page__title">{$Think.config.website.name}</h1>
            <p class="page__desc">登录</p>
        </div>

        <div class="page__bd">
            <div class="weui-cells__title">方式1:帐号登录</div>
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">
                            用户名
                        </label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input nickname" placeholder="请输入用户名" type="text">
                        </input>
                    </div>
                </div>

                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">
                            密码
                        </label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input password" placeholder="请输入密码" type="text">
                        </input>
                    </div>
                </div>
            </div>
            <div class="weui-flex">
                <div class="weui-flex__item"></div>
                <div class="weui-flex__item">
                    <a href="javascript:void(0);" class="weui-btn weui-btn_mini weui-btn_plain-primary login">登录帐号</a>

                </div>
                <div class="weui-flex__item">
                    <a href="{:url('wechat/Auth/reg')}" class="weui-btn weui-btn_mini weui-btn_plain-default">注册帐号</a>
                </div>
                <div class="weui-flex__item"></div>
            </div>


            <!--微信-->
            <div class="weui-cells__title">方式2:公众号登录</div>
            <a href="{:url('wechat/Auth/wechatLogin')}" class="weui-btn weui-btn_primary">公众号内一键登录</a>

        </div>
    </div>

</div>
</body>
<script src="__WECHAT__/js/jquery.min.js"></script>
<script src="__WECHAT__/vendors/layer/layer.js"></script>
<script type="text/javascript">
    $(function () {
        var index_url = '{:url('wechat/Index/index')}';
        var login_url = '{:url('wechat/Auth/login')}';
        $('.login').click(function () {
            var nickname = $('.nickname').val();
            var password = $('.password').val();

            if((nickname == '')||( password == '')){
                layer.open({
                    content: '用户名或密码不能为空',
                    skin: 'msg',
                    time: 1.5,
                });
            }else{
                $.post(login_url,{nickname:nickname , password: password},function (result) {
                    if(result.code == 200){
                        layer.open({
                            content: result.message,
                            skin: 'msg',
                            time: 1.5,
                            end: function () {
                                window.location.href = index_url;
                            }
                        });
                    }else{
                        layer.open({
                            content: result.message,
                            skin: 'msg',
                            time: 1.5,
                        });
                    }
                });
            }

        });

    });
</script>
</html>